package top.fongs.spring_security_jwt.configure.mybatis_plus;

import com.baomidou.mybatisplus.plugins.SqlExplainInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;


/**
 * mybatis配置
 *
 * @author fong
 */
@Configuration
@EnableTransactionManagement
@MapperScan( "top.fongs.spring_security_jwt.domain.mapper" )
public class MybatisPlusConfigurer {


    /**
     * SQL 执行分析拦截器【 目前只支持 MYSQL-5.6.3 以上版本 】，
     * 作用是分析 处理 DELETE UPDATE 语句，
     * 防止小白或者恶意 delete update 全表操作！
     *
     * @return cfg
     */
    @Bean
    public SqlExplainInterceptor sqlExplainInterceptor( ) {
        SqlExplainInterceptor sqlExplainInterceptor = new SqlExplainInterceptor( );
        sqlExplainInterceptor.setStopProceed( true );
        return sqlExplainInterceptor;
    }
}

